package com.sjh.test.java8.lambda;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class LambdaComparatorDemo {

    public static void main(String[] args)
    {
        List<String> list = Arrays.asList("Redis","Shuffer","Kafla");
        System.out.println("...排序之前...");
        for(String s : list){
            System.out.println(s);
        }

        //定义一个 comparator
        Comparator<String> comp= (String s1, String s2) -> s1.compareTo(s2);
        Collections.sort(list, comp);

        System.out.println("...排序之后...");
        for(String s : list){
            System.out.println(s);
        }
    }

}
